<template>
  <div class='deviceLog'>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="设备行为" name="first">
        <el-form :inline="true" :model="formInline" :rules="rules" ref="ruleForm" class="demo-form-inline" size='small'>
          <el-form-item label="内容关键字" prop="name">
            <el-input v-model="formInline.name" placeholder="属性名称"></el-input>
          </el-form-item>
          <el-form-item label="时间" prop="value">
            <el-select v-model="formInline.date" placeholder="时间">
              <el-option label="1小时" value="1"></el-option>
              <el-option label="4小时" value="2"></el-option>
              <el-option label="24小时" value="3"></el-option>
              <el-option label="7天" value="4"></el-option>
              <el-option label="自定义" value="5"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label=" " prop="date" v-if="formInline.date == '5'">
            <el-date-picker v-model="formInline.curTime" value-format='yyyy-MM-dd' format="yyyy-MM-dd" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" clearable>
            </el-date-picker>
          </el-form-item>
          <el-form-item label=" " prop="date">
            <el-button type="primary" @click="handleSeach" size="small">搜索</el-button>
          </el-form-item>
        </el-form>
        <el-table :data="tableData" style="width: 100%" fit border stripe size="mini" highlight-current-row :header-cell-style="{background:'#e5e5e5',color:'#000'}">
          <el-table-column prop="date" label="时间">
          </el-table-column>
          <el-table-column prop="auth" label="动作类型">
          </el-table-column>
          <el-table-column prop="type" label="内容">
          </el-table-column>
          <el-table-column prop="remark" label="状态及原因">
          </el-table-column>
        </el-table>
        <div style="text-align:right">
          <pagination v-show="pagination.total>0" :limit.sync="pagination.pageSize" :page.sync="pagination.page" :total="pagination.total" @pagination="getPageList" />
        </div>
      </el-tab-pane>
      <el-tab-pane label="历史数据" name="second">
        <el-form :inline="true" :model="formInline" :rules="rules" ref="ruleForm" class="demo-form-inline" size='small'>
          <el-form-item label="内容关键字" prop="name">
            <el-input v-model="formInline.name" placeholder="属性名称"></el-input>
          </el-form-item>
          <el-form-item label="时间" prop="value">
            <el-select v-model="formInline.date" placeholder="时间">
              <el-option label="1小时" value="1"></el-option>
              <el-option label="4小时" value="2"></el-option>
              <el-option label="24小时" value="3"></el-option>
              <el-option label="7天" value="4"></el-option>
              <el-option label="自定义" value="5"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label=" " prop="date" v-if="formInline.date == '5'">
            <el-date-picker v-model="formInline.curTime" value-format='yyyy-MM-dd' format="yyyy-MM-dd" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" clearable>
            </el-date-picker>
          </el-form-item>
          <el-form-item label=" " prop="date">
            <el-button type="primary" @click="handleSeach" size="small">搜索</el-button>
          </el-form-item>
        </el-form>
        <el-table :data="tableData" style="width: 100%" fit border stripe size="mini" highlight-current-row :header-cell-style="{background:'#e5e5e5',color:'#000'}">
          <el-table-column prop="date" label="时间">
          </el-table-column>
          <el-table-column prop="auth" label="Message ID">
          </el-table-column>
          <el-table-column prop="type" label="内容">
          </el-table-column>
          <el-table-column prop="remark" label="状态及原因">
          </el-table-column>
        </el-table>
        <div style="text-align:right">
          <pagination v-show="pagination.total>0" :limit.sync="pagination.pageSize" :page.sync="pagination.page" :total="pagination.total" @pagination="getPageList" />
        </div>
      </el-tab-pane>
      <el-tab-pane label="历史命令" name="third">
        <el-form :inline="true" :model="formInline" :rules="rules" ref="ruleForm" class="demo-form-inline" size='small'>
          <el-form-item label="内容关键字" prop="name">
            <el-input v-model="formInline.name" placeholder="属性名称"></el-input>
          </el-form-item>
          <el-form-item label="时间" prop="value">
            <el-select v-model="formInline.date" placeholder="时间">
              <el-option label="1小时" value="1"></el-option>
              <el-option label="4小时" value="2"></el-option>
              <el-option label="24小时" value="3"></el-option>
              <el-option label="7天" value="4"></el-option>
              <el-option label="自定义" value="5"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label=" " prop="date" v-if="formInline.date == '5'">
            <el-date-picker v-model="formInline.curTime" value-format='yyyy-MM-dd' format="yyyy-MM-dd" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" clearable>
            </el-date-picker>
          </el-form-item>
          <el-form-item label=" " prop="date">
            <el-button type="primary" @click="handleSeach" size="small">搜索</el-button>
          </el-form-item>
        </el-form>
        <el-table :data="tableData" style="width: 100%" fit border stripe size="mini" highlight-current-row :header-cell-style="{background:'#e5e5e5',color:'#000'}">
          <el-table-column prop="date" label="命令创建时间">
          </el-table-column>
          <el-table-column prop="auth" label="命令内容">
            <template slot="header" slot-scope="scope">
              <span>命令内容</span>
              <el-tooltip class="item" effect="dark" content="为保护用户信息安全，当前已设置不采集用户下发命令内容，如需采集，需管理员在实例管理中开启" placement="top">
                <i style="margin-left:5px;cursor: pointer;color:#0094ff" class="el-icon-warning-outline"></i>
              </el-tooltip>
            </template>
          </el-table-column>
          <el-table-column prop="type" label="响应时间">
          </el-table-column>
          <el-table-column prop="remark" label="响应内容">
            <template slot="header" slot-scope="scope">
              <span>响应内容</span>
              <el-tooltip class="item" effect="dark" content="为保护用户信息安全，当前已设置不采集设备响应内容，如需采集，需管理员在实例管理中开启" placement="top">
                <i style="margin-left:5px;cursor: pointer;color:#0094ff" class="el-icon-warning-outline"></i>
              </el-tooltip>
            </template>
          </el-table-column>
          <el-table-column prop="remark" label="状态及原因">
          </el-table-column>
        </el-table>
        <div style="text-align:right">
          <pagination v-show="pagination.total>0" :limit.sync="pagination.pageSize" :page.sync="pagination.page" :total="pagination.total" @pagination="getPageList" />
        </div>
      </el-tab-pane>
      <el-tab-pane label="消息内容查询" name="fourth">
        <el-form :inline="true" :model="formInline" :rules="rules" ref="ruleForm" class="demo-form-inline" size='small'>
          <el-form-item label="内容关键字" prop="name">
            <el-input v-model="formInline.name" placeholder="属性名称"></el-input>
          </el-form-item>
          <el-form-item label="时间" prop="value">
            <el-select v-model="formInline.date" placeholder="时间">
              <el-option label="1小时" value="1"></el-option>
              <el-option label="4小时" value="2"></el-option>
              <el-option label="24小时" value="3"></el-option>
              <el-option label="7天" value="4"></el-option>
              <el-option label="自定义" value="5"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label=" " prop="date" v-if="formInline.date == '5'">
            <el-date-picker v-model="formInline.curTime" value-format='yyyy-MM-dd' format="yyyy-MM-dd" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" clearable>
            </el-date-picker>
          </el-form-item>
          <el-form-item label=" " prop="date">
            <el-button type="primary" @click="handleSeach" size="small">搜索</el-button>
          </el-form-item>
        </el-form>
        <el-table :data="tableData" style="width: 100%" fit border stripe size="mini" highlight-current-row :header-cell-style="{background:'#e5e5e5',color:'#000'}">
          <el-table-column prop="date" label="时间">
          </el-table-column>
          <el-table-column prop="auth" label="Message ID">
          </el-table-column>
          <el-table-column prop="type" label="Topic">
          </el-table-column>
          <el-table-column prop="remark" label="内容">
            <template slot="header" slot-scope="scope">
              <span>内容</span>
              <el-tooltip class="item" effect="dark" content="为保护用户信息安全，当前已设置不采集设备响应内容，如需采集，需管理员在实例管理中开启" placement="top">
                <i style="margin-left:5px;cursor: pointer;color:#0094ff" class="el-icon-warning-outline"></i>
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      activeName: 'first',

      tableData: [{ date: "2021-07-05 16:47:54.671" }],
      pagination: {
        total: 1,
        page: 1,
        pageSize: 10
      },
      formInline: {
        name: '',
        value: '',
        date: "1",
        curTime: []
      },
      rules: {
        name: [
          { required: true, message: '请填写属性名称', trigger: 'blur' }
        ],
        value: [
          { required: true, message: '请填写属性值', trigger: 'blur' }
        ],
      }
    }
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //生命周期 - 创建完成（可以访问当前this实例）
  created() { },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() { },
  methods: {
    handleClick(tab, event) {
      // console.log(tab, event);
    },
    getPageList() {
      this.search()
    },
    search() {
      const p = Object.assign({}, this.pagination)
      // api.page(p).then(resp => {
      //   this.tableData = resp.data.list
      //   this.pagination = resp.data.pagination
      //   this.pagination.page = resp.data.pagination.current
      // })
    },
    handleSeach() { },
  },
}
</script>
<style lang='scss' scoped>
.deviceLog {
  padding: 10px;
}
</style>